package ru.ifmo.kis.domain;

/**
 *
 * @author ivan
 */
public class OrderedProduct {
    private Order order;
    private Product product;
    private int startTime;

    public OrderedProduct(Order order, Product product) {
        this.order = order;
        this.product = product;
    }

    public Order getOrder() {
        return order;
    }

    public void setStartTime(int startTime) {
        this.startTime = startTime;
    }

    public int getFinishTime() {
        return startTime + product.getDuration();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final OrderedProduct other = (OrderedProduct) obj;
        if (this.product != other.product && (this.product == null || !this.product.equals(other.product))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + (this.product != null ? this.product.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return product.toString() + order.toString();
    }


}
